package day09.LinkedListTest;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

// abcabcabc
public class homework2 {
    public static void main(String[] args) {
        System.out.print("请输入字符串:");
        String input = new Scanner(System.in).nextLine();
        System.out.print("输入要查找的字符串: ");
        String subStr = new Scanner(System.in).nextLine();
        LinkedList<Integer> li1 = findIndexofSubString(input, subStr);
        //int index= input.indexOf(subStr);
        System.out.println(li1);
    }

    private static LinkedList<Integer> findIndexofSubString(String input, String subStr) {
        int index = 0;
        int i = 0;
        LinkedList<Integer> li = new LinkedList<>();
        while(index < input.length()){
            index = input.indexOf(subStr, index);
            if(index == -1){
                break;
            }
            li.add(index);
            index++;
            i++;
            if(index >= input.length()){
                break;
            }
        }
        return li;
    }
}
